<?php

namespace App\Admin\Requests;

use App\Rules\Setting\IsVaildNameRule;
use App\Rules\Setting\IsNameExistedRule;

class SettingStoreRequest extends Request
{
    public function rules()
    {
        return [
            'type'  => ['required', 'max:20', new IsVaildNameRule],
            'name'  => ['required', 'max:50', new IsVaildNameRule, new IsNameExistedRule(request('type'))],
            'value' => 'required',
        ];
    }

    public function messages()
    {
        return [
            'type.required'  => '配置類型不能為空',
            'name.required'  => '配置項不能為空',
            'value.required' => '配置值不能為空',
        ];
    }
}
